﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsBlockNode : OdGsNode
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsBlockNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsBlockNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsBlockNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsBlockNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsBlockNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsBlockNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBlockNode_cast(OdRxObject.getCPtr(pObj));
			OdGsBlockNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsBlockNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBlockNode_createObject();
			OdGsBlockNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsBlockNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsBlockNode(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setUnloaded(bool isUnloaded)
		{
			GlobalsPINVOKE.OdGsBlockNode_setUnloaded(this.swigCPtr, isUnloaded);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isUnloaded()
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_isUnloaded(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setModelTfDependent(bool bOn)
		{
			GlobalsPINVOKE.OdGsBlockNode_setModelTfDependent(this.swigCPtr, bOn);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isModelTfDependent()
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_isModelTfDependent(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual ENodeType nodeType()
		{
			ENodeType result = (ENodeType)GlobalsPINVOKE.OdGsBlockNode_nodeType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl view, uint mask)
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(view), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool extents(OdGeExtents3d arg0)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_extents(this.swigCPtr, OdGeExtents3d.getCPtr(arg0));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void propagateLayerChanges(OdGsViewImpl arg0)
		{
			GlobalsPINVOKE.OdGsBlockNode_propagateLayerChanges(this.swigCPtr, OdGsViewImpl.getCPtr(arg0));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroy()
		{
			GlobalsPINVOKE.OdGsBlockNode_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateShared()
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidateShared(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateSharedSubents(uint vpID, uint nViewChanges)
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidateSharedSubents(this.swigCPtr, vpID, nViewChanges);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateSharedRegenDraw(uint vpID, OdDbStub layoutId)
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidateSharedRegenDraw(this.swigCPtr, vpID, OdDbStub.getCPtr(layoutId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateSharedSectionable()
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidateSharedSectionable(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateSharedAwareFlags(OdGsViewImpl pView, uint nViewChanges, OdDbStub layoutId)
		{
			GlobalsPINVOKE.OdGsBlockNode_invalidateSharedAwareFlags(this.swigCPtr, OdGsViewImpl.getCPtr(pView), nViewChanges, OdDbStub.getCPtr(layoutId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool findDef(SWIGTYPE_p_OdGsSharedRefDefinition pDef, OdGsBlockRefNodeDesc d)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_findDef(this.swigCPtr, SWIGTYPE_p_OdGsSharedRefDefinition.getCPtr(pDef), OdGsBlockRefNodeDesc.getCPtr(d));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_saveNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_saveNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_loadNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_loadNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool postprocessNodeLoading(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsBlockNode_postprocessNodeLoading(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
